/****************************************************************
 *  YAG2002 (http://yag2002.sourceforge.net)
 *  Copyright (C) 2005-2006, A. Botorabi
 *
 *  This program is free software; you can redistribute it and/or 
 *  modify it under the terms of the GNU Lesser General Public 
 *  License version 2.1 as published by the Free Software Foundation.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public 
 *  License along with this program; if not, write to the Free 
 *  Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, 
 *  MA  02111-1307  USA
 * 
 ****************************************************************/

/*###############################################################
 # player's main mailbox gui implementation
 #
 #   date of creation:  01/08/2008
 #
 #   author:            boto (botorabi at users.sourceforge.net) 
 #
 ****************************************************************/

#ifndef _VRC_MAILBOXGUIMAIN_H_
#define _VRC_MAILBOXGUIMAIN_H_

#include <vrc_main.h>
#include <storage/vrc_mailboxclient.h>

namespace vrc
{

class MailboxGui;
class MailboxGuiView;
class MailboxGuiSend;

//! Class for player's main mailbox gui
class MailboxGuiMain : public MailboxResponseCallback
{
    public:

        //! Construct the main gui given the gui file name.
                                                    MailboxGuiMain( MailboxGui* p_mailbox, const std::string& filename );

        virtual                                     ~MailboxGuiMain();

        //! Get the frame object
        CEGUI::FrameWindow*                         getFrame();

        //! Request for a mailbox content update
        void                                        updateMailbox();

    protected:

        //! Setup the GUI
        void                                        setupGui( const std::string& filename );

        //! Callback: Get the user ID the mailbox belongs to.
        unsigned int                                mailboxGetUserID() const;

        //! Callback: Get the mailbox request response. The response string and status are generated by the mail server.
        void                                        mailboxResponse( const MailboxContent& mailcontent, unsigned int status, const std::string& response );

        //! Callback for button and close control
        bool                                        onClickedClose( const CEGUI::EventArgs& arg );

        //! Callback for button send
        bool                                        onClickedSend( const CEGUI::EventArgs& arg );

        //! Callback for changed folder selection
        bool                                        onFolderSelChanged( const CEGUI::EventArgs& arg );

        //! Callback for button update
        bool                                        onClickedUpdate( const CEGUI::EventArgs& arg );

        //! Callback for button view
        bool                                        onClickedView( const CEGUI::EventArgs& arg );

        //! Callback for reply button
        bool                                        onClickedReply( const CEGUI::EventArgs& arg );

        //! Callback for delete button
        bool                                        onClickedDelete( const CEGUI::EventArgs& arg );

        //! Called when the view window requests for closing.
        void                                        viewOnClose();

        //! Called when the send window requests for closing.
        void                                        sendOnClose();

        //! Main gui object
        MailboxGui*                                 _p_mailboxGui;

        //! Child window for viewing a mail
        MailboxGuiView*                             _p_mailboxGuiView;

        //! Child window for sending a mail
        MailboxGuiSend*                             _p_mailboxGuiSend;

        //! Frame object
        CEGUI::FrameWindow*                         _p_frame;

        //! Mailbox folder list
        CEGUI::Listbox*                             _p_listFolders;

        //! Mailbox header list
        CEGUI::Listbox*                             _p_listHeaders;

    friend class MailboxGuiView;
    friend class MailboxGuiSend;
};

} // namespace vrc

#endif // _VRC_MAILBOXGUIMAIN_H_
